﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entities.Enums;

namespace Entities
{
    public class QuestionRunResultData
    {
        public int QuestionID { get; set; }
        public List<int> MultiplePicked { get; set; }
        public int SinglePicked { get; set; }
        public string TextAnswer { get; set; }

        public QuestionType Type { get; private set; }

        
        
        public QuestionRunResultData(int question_id, object result_object, QuestionType type = QuestionType.TextInput)
        {
            this.QuestionID = question_id;

            this.Type = type;

            if (result_object == null)
            {
                throw new ArgumentNullException();
            }

            if (result_object is List<int>)
            {
                this.MultiplePicked = (List<int>)result_object;
                return;
            }

            if (result_object is int)
            {
                this.SinglePicked = (int)result_object;
                return;
            }

            if (result_object is string)
            {
                this.TextAnswer = (string)result_object;
                return;
            }

            throw new ArgumentException();
        }
    }
}
